package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.EnergyDevRepairRecordDao;
import com.sugon.entity.EnergyDevRepairRecord;
import com.sugon.service.EnergyDevRepairRecordService;
import com.sugon.utils.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 维修记录单Service实现类
 *
 * @author sugon
 * @date 2019-07-18 11:39:51
 */
@Service("energyDevRepairRecordService")
public class EnergyDevRepairRecordServiceImpl implements EnergyDevRepairRecordService {

    @Autowired
    private EnergyDevRepairRecordDao energyDevRepairRecordDao;

    /**
     * queryObject
     *
     * @param id 维修记录ID或维修工单ID
     * @return
     */
    @Override
    public EnergyDevRepairRecord queryObject(String id) {
        return energyDevRepairRecordDao.queryObject(id);
    }

    /**
     * queryList
     *
     * @param map 参数
     * @return
     */
    @Override
    public List<EnergyDevRepairRecord> queryList(Map<String, Object> map) {
        return energyDevRepairRecordDao.queryList(map);
    }

    /**
     * queryTotal
     *
     * @param map 参数
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return energyDevRepairRecordDao.queryTotal(map);
    }

    /**
     * save
     *
     * @param devMaintenRepair 实体
     * @return
     */
    @Override
    public int save(EnergyDevRepairRecord devMaintenRepair) {
        devMaintenRepair.setId(RandomUtil.randomString(32));
        if (devMaintenRepair.getDelFlag() == null) {
            devMaintenRepair.setDelFlag(Constant.IS_NOT_DEL_INT);
        }
        devMaintenRepair.setGmtCreate(DateUtil.date());
        return energyDevRepairRecordDao.save(devMaintenRepair);
    }

    /**
     * update
     *
     * @param devMaintenRepair 实体
     * @return
     */
    @Override
    public int update(EnergyDevRepairRecord devMaintenRepair) {
        return energyDevRepairRecordDao.update(devMaintenRepair);
    }

    /**
     * delete
     *
     * @param id
     * @return
     */
    @Override
    public int delete(String id) {
        return energyDevRepairRecordDao.delete(id);
    }

    /**
     * deleteBatch
     *
     * @param ids
     * @return
     */
    @Override
    public int deleteBatch(String[] ids) {
        return energyDevRepairRecordDao.deleteBatch(ids);
    }

}
